import java.util.Arrays;

//2、将一个字符串从左开始前k个字符进行旋转：左旋数组 。例如字符串："abcdef"，前2个左旋结果
//是："cdefab"。
public class Text2 {
    public static void LeftRotateString(String str,int n){
            char[] ch=str.toCharArray();
               int left1=0;
               int right1=n-1;
               int left2=n;
               int right2=str.length()-1;
           str=reverseString(str,left1,right1);
           str=reverseString(str,left2,right2);
           str=reverseString(str,left1,right2);
              System.out.println(str);
    }
        //反转字符串
    public static String reverseString(String str,int left,int right) {
        char[] ch=str.toCharArray();
        while(left<right){
            char tmp=ch[left];
            ch[left]=ch[right];
            ch[right]=tmp;
            left++;
            right--;
        }
        return String.copyValueOf(ch);
    }
    public static void main(String[] args) {
            String str="abcdef";
            LeftRotateString(str,2);
    }
}
